package com.ant.map.myuiimmersive;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

import com.ant.map.myuiimmersive.activities.Test001;
import com.ant.map.myuiimmersive.activities.Test0010;
import com.ant.map.myuiimmersive.activities.Test002;
import com.ant.map.myuiimmersive.activities.Test003;
import com.ant.map.myuiimmersive.activities.Test004;
import com.ant.map.myuiimmersive.activities.Test005;
import com.ant.map.myuiimmersive.activities.Test006;
import com.ant.map.myuiimmersive.activities.Test007;
import com.ant.map.myuiimmersive.activities.Test008;
import com.ant.map.myuiimmersive.activities.Test009;
import com.ant.utls.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity implements View.OnClickListener {
    private Button obt01;
    private ListView lv;

    private ArrayAdapter<String> adapter;

    private List<String> title;
    private List<Class> activities;

    @Override
    public int getLaout() {
        title = new ArrayList<>();
        activities = new ArrayList<>();
        return R.layout.activity_main;
    }

    @Override
    public void initView() {
        obt01 = (Button) findViewById(R.id.ac_main_obt01);
        lv = (ListView) findViewById(R.id.ac_main_lv001);
    }

    @Override
    public void initData() {
        getListData();
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, title);
        lv.setAdapter(adapter);
    }


    public void getListData() {
        title.add("test001");
        activities.add(Test001.class);
        title.add("Test002");
        activities.add(Test002.class);
        title.add("Test003");
        activities.add(Test003.class);
        title.add("test004");
        activities.add(Test004.class);
        title.add("test005 recycleView");
        activities.add(Test005.class);

        title.add("test006 test");
        activities.add(Test006.class);
        title.add("test007 test");
        activities.add(Test007.class);
        title.add("test008 test");
        activities.add(Test008.class);
        title.add("test009 test");
        activities.add(Test009.class);
        title.add("test0010 test");
        activities.add(Test0010.class);
    }

    @Override
    public void initListener() {
        obt01.setOnClickListener(this);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                MainActivity.this.startActivity(new Intent(MainActivity.this, activities.get(i)));
            }
        });
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.ac_main_obt01:
                startActivity(new Intent(this, Test001.class));
                break;
        }
    }


}
